#include "mylistview.h"
#include "ui_mylistview.h"
#include<QDebug>
MyListView::MyListView(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MyListView)
{
    ui->setupUi(this);
    // 设置不可编译
    ui->listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    // 连接QListView的双击信号到槽函数
    connect(ui->listView, &QListView::doubleClicked, this, &MyListView::getIndexData);
}

MyListView::~MyListView()
{
    delete ui;
}

void MyListView::setSongList(QStandardItemModel *&songList)
{
    ui->listView->setModel(songList);
}

void MyListView::getIndexData(const QModelIndex &index)
{
    // 获取当前双击的项目数据
    QString songName = index.data().toString();
    // 处理获取到的当前内容
    emit selectSongName(songName);
}

